package com.hang.ad.advice;

import com.hang.ad.exceptions.AdException;
import com.hang.ad.vo.CommonResponse;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

@RestControllerAdvice
public class GlobalExceptionAdvice {
    @ExceptionHandler(value = AdException.class)
    public CommonResponse<String> handle(HttpServletRequest request, AdException e){
        CommonResponse<String> result = new CommonResponse<String>(-1,"Ad异常");
        result.setData(e.getMessage());
        return result;
    }
}
